home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / TEST / OVERKILL.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  4.5 KB  |  146 lines

  1. /*
  2.  * $Id: overkill_test.java,v 1.8 1996/10/03 19:46:51 hudson Exp $
  3.  * $Author: hudson $
  4.  */
  5.  
  6. package sub_arctic.test;
  7.  
  8. import sub_arctic.constraints.std_function;
  9. import sub_arctic.lib.interactor_applet;
  10. import sub_arctic.lib.base_parent_interactor;
  11. import sub_arctic.lib.debug_interactor_applet;
  12. import sub_arctic.lib.manager;
  13. import sub_arctic.lib.interactor;
  14. import sub_arctic.lib.interactor_consts;
  15. import sub_arctic.lib.top_level;
  16. import sub_arctic.lib.icon;
  17. import sub_arctic.lib.line_display;
  18. import sub_arctic.lib.shadow_drag_container;
  19. import sub_arctic.lib.anim_mover_container;
  20. import sub_arctic.lib.button;
  21. import sub_arctic.anim.anticipation_line;
  22. import sub_arctic.anim.line_trajectory;
  23. import sub_arctic.anim.trajectory;
  24. import sub_arctic.anim.slow_in_slow_out;
  25. import sub_arctic.anim.transition;
  26. import sub_arctic.anim.time_interval;
  27. import sub_arctic.input.callback_object;
  28. import sub_arctic.input.event;
  29.  
  30. public class overkill_test extends debug_interactor_applet 
  31. implements interactor_consts, callback_object {
  32.  
  33.   protected anim_mover_container mover;
  34.  
  35.   public void build_ui(base_parent_interactor top) 
  36.     {
  37.       interactor            child;
  38.       shadow_drag_container drag;
  39.       slow_in_slow_out      pace;
  40.       trajectory            path;
  41.       transition            trans;
  42.       long                  now;
  43.       time_interval         interv;
  44.  
  45.       /* create a shadow drag container to put everything in */
  46.       drag = new shadow_drag_container(0,0);
  47.       // drag.set_expensive_draw(true);
  48.       top.add_child(drag);
  49.  
  50.       /* add an icon */
  51.       try {
  52.     child = new icon(10,10,manager.load_doc_image(this,"images/gvu.gif"));
  53.     drag.add_child(child);
  54.     
  55.     /* add an icon inside a sprite container */
  56.     child = new icon(75,25,manager.load_doc_image(this,"images/gvu.gif"));
  57.     mover = new anim_mover_container(75,25, child, this);
  58.     drag.add_child(mover);
  59.       } catch (java.net.MalformedURLException e) {
  60.     System.out.println("unable to load the GVU logo!");
  61.     return;
  62.       }
  63.       /* schedule the initial transition for the container */
  64.       if (animation_on) schedule_anim();
  65.  
  66.       /* put in two lines */
  67.       child = new line_display(170,10, 370,95, 2);
  68.       drag.add_child(child);
  69.       child = new line_display(170,95, 370,10, 2);
  70.       drag.add_child(child);
  71.  
  72.     /* and a coord_tracker */
  73.       child = new coord_tracker(10,100, "Shadow drag any interactors! [","]");
  74.       drag.add_child(child);
  75.  
  76.         /* put a button in to control the animation */
  77.       child = new button(drag.w()+10,0,"Start/Stop Animation", this);
  78.       top.add_child(child);
  79.     }
  80.  
  81.   /* transition counter so we know direction */
  82.   protected int count = 1;
  83.  
  84.   protected boolean animation_on = false;
  85.  
  86.   /* schedule an animation transition */
  87.   protected void schedule_anim()
  88.     {
  89.       slow_in_slow_out      pace;
  90.       trajectory            path;
  91.       transition            trans;
  92.       long                  now;
  93.       time_interval         interv;
  94.  
  95.       count++;
  96.       now = time_interval.now();
  97.       pace = new slow_in_slow_out(0.35, 0.2);
  98.       if (count % 2 == 0)
  99.         path = new anticipation_line(75,25, 300, 24, pace);
  100.       else
  101.         path = new anticipation_line(300,26, 75,25, pace);
  102.       interv = new time_interval(now+500,now+3500);
  103.       trans = new transition(mover, interv, path);
  104.       mover.set_transition(trans);
  105.     }
  106.  
  107.   /* callback from animation ... */
  108.   public void callback(
  109.     interactor from_obj, 
  110.     event      evt,
  111.     int        callback_num,  
  112.     Object info) 
  113. {
  114.  
  115.       /* when we get the callback for the end of the transition, schedule 
  116.        * a new one */
  117.       if (from_obj instanceof anim_mover_container && 
  118.       callback_num == anim_mover_container.END_TRANSITION_CALLBACK)
  119.     {
  120.       if (animation_on) schedule_anim();
  121.     }
  122.       else if (from_obj instanceof button)
  123.     {
  124.       animation_on = !animation_on;
  125.       if (animation_on) schedule_anim();
  126.     }
  127.     }
  128. }
  129.  
  130. /*=========================== COPYRIGHT NOTICE ===========================
  131.  
  132. This file is part of the subArctic user interface toolkit.
  133.  
  134. Copyright (c) 1996 Scott Hudson and Ian Smith
  135. All rights reserved.
  136.  
  137. The subArctic system is freely available for most uses under the terms
  138. and conditions described in 
  139.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  140. and appearing in full in the lib/interactor.java source file.
  141.  
  142. The current release and additional information about this software can be 
  143. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  144.  
  145. ========================================================================*/
  146.